﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DTO;


namespace DAO
{
    public class ThucDon_DAO
    {
        // Connection con;

        public ThucDon_DAO()
        {
            // con = new Connection();
        }

        public DataSet Lich_Tuan_Ngay(int loai, int tuan)
        {
            DataSet dtset = new DataSet();

            Connection con = new Connection(loai);
            try
            {
                dtset = con.ExecuteDataTable("Lich_Tuan_Ngay", CommandType.StoredProcedure, "@Tuan", tuan);
            

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return dtset;
        }
        public DataSet Lich_Tuan(int loai)
        {
            DataSet dtset = new DataSet();
            Connection con = new Connection(loai);
            try
            {
                dtset = con.ExecuteDataTable("Lich_Tuan", CommandType.StoredProcedure);
                int count = dtset.Tables.Count;
                Console.Write(count.ToString());

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return dtset;
        }
        public DataSet DSThucDon_TuanNgay(int loai, int tuan, int ngay)
        {
            DataSet dtset = new DataSet();
            Connection con = new Connection(loai);
            try
            {
                dtset = con.ExecuteDataTable("ds_ThucDon_TheoTuanNgay", CommandType.StoredProcedure, "@tuan", tuan, "@ngay", ngay);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return dtset;
        }
        public Boolean Delete_ThucDon(int loai, int tuan, int ngay)
        {
            Boolean flag = true;
            Connection con = new Connection(loai);
            try
            {
                string store = "delete_thucdon";
                con.ExecuteNonQuery(store, CommandType.StoredProcedure, "@tuan", tuan, "@ngay", ngay);
            }
            catch (Exception ex)
            {
                flag = false;
                Console.WriteLine(ex.Message);
            }
            return flag;
        }
    }
}
